package com.six.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.six.domain.vo.BizOrderDetailVO;
import com.six.domain.vo.BizOrderVO;
import com.six.service.BizOrderService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/manager/order")
@RequiredArgsConstructor
public class BizOrderController {

    private final BizOrderService bizOrderService;

    @GetMapping
    public IPage<BizOrderVO> list(@RequestParam Long storeId,
                                  @RequestParam(defaultValue = "1") Integer page,
                                  @RequestParam(defaultValue = "10") Integer size,
                                  @RequestParam(required = false) Integer status) {
        return bizOrderService.listByStore(storeId, page, size, status);
    }

    @GetMapping("/{id}")
    public BizOrderDetailVO detail(@PathVariable Long id) {
        return bizOrderService.detail(id);
    }

    @PutMapping("/{id}/status")
    public void status(@PathVariable Long id,
                       @RequestParam Integer status) {
        bizOrderService.updateStatus(id, status);
    }
}